import { IPSDEUILogic, IPSDEUILogicParam } from '../..';
import { IPSModelObject } from '../../ipsmodel-object';
import { PSModelServiceProxyImpl } from '../../psmodel-service-proxy-impl';

/**
 * 全局默认通用代理
 *
 * @author chitanda
 * @date 2021-06-08 20:06:55
 * @export
 * @class PSDEUILogicNodeParamServiceProxy
 * @extends {PSModelServiceProxyImpl}
 */
export class PSDEUILogicNodeParamServiceProxy extends PSModelServiceProxyImpl {
  getPSModel4(
    relatedPSModelObject: IPSModelObject,
    cls: string,
    objNode: any,
    strTag: string,
  ): IPSModelObject {
    switch (strTag) {
      case 'getDstPSDEUILogicParam':
      case 'getSrcPSDEUILogicParam':
        return this.getPSDEUILogicParam(
          relatedPSModelObject as IPSDEUILogicParam,
          objNode,
        );
    }
    return this.getRealPSModelService().getPSModel4(
      relatedPSModelObject,
      cls,
      objNode,
      strTag,
    );
  }

  getPSDEUILogicParam(relatedPSModelObject: IPSDEUILogicParam, obj: any): any {
    if (obj.modelref) {
      const modelObj = this.getParentPSModelObject(
        relatedPSModelObject,
        'app.dataentity.IPSAppDEUILogic',
      ) as IPSDEUILogic;
      if (modelObj) {
        return modelObj.findPSDEUILogicParam(obj);
      }
    }
    return null;
  }
}
